var t = getApp()
Page({

    data:{
      list:[{
        icon:"/icons/boorico_1.png",
        title:"24h营业"
      },{
        icon:"/icons/boorico_2.png",
        title:"方便快捷"
      },
      {
        icon:"/icons/boorico_3.png",
        title:"无人值守"
      } ],
      list1:[{

          icon:"/icons/boorico_4.png",
          title:"全年不涨价"
        },
        {
          icon:"/icons/boorico_5.png",
          title:"扫码开门"
        },
        {
          icon:"/icons/boorico_6.png",
          title:"专业设备"
        }
      ],
      navHeight:t.globalData.navHeight,
      title:'扫码开门',
      on: true
    },
    onRefresh(){
      //在当前页面显示导航条加载动画
      wx.showNavigationBarLoading(); 
      //显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
    },
    onPullDownRefresh: function () {
      //调用刷新时将执行的方法
      this.onRefresh();
      setTimeout(function () {
        // 不加这个方法真机下拉会一直处于刷新状态，无法复位
        wx.stopPullDownRefresh()
      }, 1000)
    },
    onShow(e){
      console.log('onShow')
      var that = this
      if (that.data.on) {
        var call = that.data.call
        wx.scanCode({
          success: (res) => {
            if (res.path) {
              console.log(res.path);
              wx.navigateTo({
                url: '/' + res.path,
              })
            }
          },
          fail: (err) => {
            console.log(err, 'fail')
            wx.switchTab({
              url: '/pages/index/index',
            })
          }
        })
      }
      /*
      var that = this
      wx.login({
        success: res => {
          t.request('/login',{code:res.code},function(r){
            t.globalData.token = r.result.token;
            wx.setStorageSync('token', r.result.token);
            wx.setStorageSync('userinfo', r.result.userInfo)
            console.log(r.result.userInfo);
            if(r.result.userInfo.cars == 0){
              // t.show_login()
            }else{
              t.globalData.show_login = false;
            }
          })
        }
      })*/
    },
    onHide: function () {
      var that = this
      var on = that.data.on
      that.setData({
        on: !on
      })
    },
    getScancode: function() {
      var _this = this;
      // 允许从相机和相册扫码
      wx.scanCode({
        success: (res) => {
          if (res.path) {
            console.log(res.path);
            wx.navigateTo({
              url: '/' + res.path,
            })
          }
        }
      })
    }
})